////////////////////////////////////////////////////////////
//
// Module SCSIDEFS.H
//
// ASPI class library
// SCSI structures and definitions
//
// Project: A Programmer's Guide to SCSI
//
// Copyright (C) 1997, Brian Sawert
// Portions copyright (C) 1995, Larry Martin
// All rights reserved
//
////////////////////////////////////////////////////////////


#ifndef SCSIDEFS_H_INCLUDED
#define SCSIDEFS_H_INCLUDED

#pragma pack(push,1)

#define SCSI_GET_RPC			0x08

#define SCSI_READ_DVD_ROM		0x10


#define SCSI_Cmd_Timeout		300

#define SCSI_Cmd_TestUnitReady        0x00
#define SCSI_Cmd_Rewind               0x01
#define SCSI_Cmd_RequestSense         0x03
#define SCSI_Cmd_FormatUnit           0x04
#define SCSI_Cmd_ReadBlockLimits      0x05
#define SCSI_Cmd_Read                 0x08
#define SCSI_Cmd_Write                0x0A
#define SCSI_Cmd_WriteFilemarks       0x10
#define SCSI_Cmd_Space                0x11
#define SCSI_Cmd_Inquiry              0x12
#define SCSI_Cmd_ModeSelect           0x15
#define SCSI_Cmd_ReserveUnit          0x16
#define SCSI_Cmd_ReleaseUnit          0x17
#define SCSI_Cmd_ModeSense6           0x1A
#define SCSI_Cmd_LoadUnload           0x1B
#define SCSI_Cmd_SendDiagnostic       0x1D
#define SCSI_Cmd_PreventAllow         0x1E
#define SCSI_Cmd_ReadFormatCapacities 0x23
#define SCSI_Cmd_ReadCapacity         0x25
#define SCSI_Cmd_Read10				  0x28
#define SCSI_Cmd_Write10			  0x2A
#define SCSI_Cmd_Seek	              0x2B
#define SCSI_Cmd_Erase			      0x2C
#define SCSI_Cmd_SetLimits			  0x33
#define SCSI_Cmd_ReadPosition         0x34
#define SCSI_Cmd_WriteBuffer          0x3B
#define SCSI_Cmd_ReadBuffer           0x3C
#define SCSI_Cmd_ReadSubChannel		  0x42
#define SCSI_Cmd_ReadToc              0x43
#define SCSI_Cmd_GetConfiguration     0x46
#define SCSI_Cmd_GetEventStatus	      0x4A
#define SCSI_Cmd_ReadDiscInformation  0x51
#define SCSI_Cmd_ReadTrackInformation 0x52
#define SCSI_Cmd_SendOPCInformation	  0x54
#define SCSI_Cmd_ModeSelect10		  0x55
#define SCSI_Cmd_ModeSense10	      0x5A
#define SCSI_Cmd_CloseTrackSession	  0x5B
#define SCSI_Cmd_Blank                0xA1
#define SCSI_Cmd_SendKey	  	      0xA3 
#define SCSI_Cmd_ReportKey  	      0xA4 
#define SCSI_Cmd_Read12				  0xA8
#define SCSI_Cmd_GetPerformance	      0xAC
#define SCSI_Cmd_ReadDvdStruct	      0xAD
#define SCSI_Cmd_ReadDiscStructure    0xAD  //new name in MMC6
#define SCSI_Cmd_SetStreaming	      0xB6
#define SCSI_Cmd_SetSpeed			  0xBB
#define SCSI_Cmd_SetSpeed2			  0xDA
#define SCSI_Cmd_MechanismStatus      0xBD
#define SCSI_Cmd_ReadAudioCd		  0xBE

//=================================================
// SCSI COMMANDS FOR MAGNETIC DISKS
//=================================================
#define SCSI_Hdd_CHANGE_DEFINITION				0x40
#define SCSI_Hdd_COMPARE						0x39
#define SCSI_Hdd_COPY							0x18
#define SCSI_Hdd_COPY_AND_VERIFY				0x3A
#define SCSI_Hdd_FORMAT_UNIT					0x04
#define SCSI_Hdd_INQUIRY						0x12
#define SCSI_Hdd_LOCK_UNLOCK_CACHE				0x36
#define SCSI_Hdd_LOG_SELECT						0x4C
#define SCSI_Hdd_LOG_SENSE						0x4D
#define SCSI_Hdd_MODE_SELECT6					0x15
#define SCSI_Hdd_MODE_SELECT10					0x55
#define SCSI_Hdd_MODE_SENSE6					0x1A
#define SCSI_Hdd_MODE_SENSE10					0x5A
#define SCSI_Hdd_MOVE_MEDIUM					0xA7
#define SCSI_Hdd_PERSISTENT_RESERVE_IN			0x5E
#define SCSI_Hdd_PERSISTENT_RESERVE_OUT			0x5F
#define SCSI_Hdd_PREFETCH						0x34
#define SCSI_Hdd_PREVENTALLOW_MEDIUM_REMOVAL	0x1E
#define SCSI_Hdd_READ6							0x08
#define SCSI_Hdd_READ10							0x28
#define SCSI_Hdd_READ12							0xA8
#define SCSI_Hdd_READ_BUFFER					0x3C
#define SCSI_Hdd_READ_CAPACITY					0x25
#define SCSI_Hdd_READ_DEFECT_DATA10				0x37
#define SCSI_Hdd_READ_DEFECT_DATA12				0xB7
#define SCSI_Hdd_READ_ELEMENT_STATUS			0xB4
#define SCSI_Hdd_READ_LONG						0x3E
#define SCSI_Hdd_REASSIGN_BLOCKS				0x07
#define SCSI_Hdd_REBUILD						0x81
#define SCSI_Hdd_RECEIVE_DIAGNOSTIC_RESULTS		0x1C
#define SCSI_Hdd_REGENERATE						0x82
#define SCSI_Hdd_RELEASE6						0x17
#define SCSI_Hdd_RELEASE10						0x57
#define SCSI_Hdd_REPORT_LUNS					0xA0
#define SCSI_Hdd_REQUEST_SENSE					0x03
#define SCSI_Hdd_SEEK10							0x2B
#define SCSI_Hdd_SEND_DIAGNOSTIC				0x1D
#define SCSI_Hdd_SET_LIMITS10					0x33
#define SCSI_Hdd_SET_LIMITS12					0xB3
#define SCSI_Hdd_START_STOP UNIT				0x1B
#define SCSI_Hdd_SYNCHRONIZE_CACHE				0x35
#define SCSI_Hdd_TEST_UNIT_READY				0x00
#define SCSI_Hdd_VERIFY							0x2F
#define SCSI_Hdd_WRITE6							0x0A
#define SCSI_Hdd_WRITE10						0x2A
#define SCSI_Hdd_WRITE12						0xAA
#define SCSI_Hdd_WRITE_AND_VERIFY				0x2E
#define SCSI_Hdd_WRITE_BUFFER					0x3B
#define SCSI_Hdd_WRITE_LONG						0x3F
#define SCSI_Hdd_WRITE_SAME						0x41
#define SCSI_Hdd_XDREAD							0x52
#define SCSI_Hdd_XDWRITE						0x50
#define SCSI_Hdd_XDWRITE_EXTENDED				0x80
#define SCSI_Hdd_XPWRITE						0x51

//***************************************************************************
//                %%% PERIPHERAL DEVICE TYPE DEFINITIONS %%%
//***************************************************************************
#define DTYPE_DASD      0x00    // Disk Device
#define DTYPE_SEQD      0x01    // Tape Device
#define DTYPE_PRNT      0x02    // Printer
#define DTYPE_PROC      0x03    // Processor
#define DTYPE_WORM      0x04    // Write-once read-multiple
#define DTYPE_CROM      0x05    // CD-ROM device
#define DTYPE_CDROM     0x05    // CD-ROM device
#define DTYPE_SCAN      0x06    // Scanner device
#define DTYPE_OPTI      0x07    // Optical memory device
#define DTYPE_JUKE      0x08    // Medium Changer device
#define DTYPE_COMM      0x09    // Communications device
#define DTYPE_RESL      0x0A    // Reserved (low)
#define DTYPE_RESH      0x1E    // Reserved (high)
#define DTYPE_UNKNOWN   0x1F    // Unknown or no device type


/* ********************* WARNING ********************************** */
/* The structures below expect that the compiler lays out bitfields */
/* LSB first.                                         */
/* **************************************************************** */

typedef struct _CDMP30 {               // Buffer Underrun Free Control Page 
   BYTE   PageCode : 6; 
   BYTE   PageReserved : 2; 
   BYTE   PageLength;                        // 0x0E = 14 
   BYTE   UnderrunSupport:1;            // Buffer Underrun Error Free Support 
   BYTE   TestBurnFreeSupport:1;
   BYTE   Reserved2:2;
   BYTE	  ARSCS:1;							//AutoReadSpeedControlSupport	
   BYTE   AWSCS:1;							//AutoWriteSpeedControlSupport
   BYTE   Reserved2_1:2;
   BYTE   UnderrunEnable:1;               // Buffer Underrun Error Free Enable 
   BYTE   Reserved2_2:3;
   BYTE	  ARSCE:1;							//AutoReadSpeedControlEnabled	
   BYTE   AWSCD:1;							//AutoWriteSpeedControlDisabled
   BYTE   Reserved3:2; 
   BYTE   LinkCounter[2];                  // Number of Underruns Detected 
   BYTE   Reserved6[10]; 
} CDMP30;  

//struct ricoh_mode_page_30 { 
//      MP_P_CODE;      /* parsave & pagecode */ 
//   Uchar   p_len;         /* 0xE = 14 Bytes */ 
//   Ucbit   BUEFS      :1;   /* Burn-Free supported   */ 
//   Ucbit   TWBFS      :1;   /* Test Burn-Free sup.   */ 
//   Ucbit   res_2_23   :2; 
//   Ucbit   ARSCS      :1;   /* Auto read speed control supp. */ 
//   Ucbit   AWSCS      :1;   /* Auto write speed control supp. */ 
//   Ucbit   res_2_67   :2; 
//   Ucbit   BUEFE      :1;   /* Burn-Free enabled   */ 
//   Ucbit   res_2_13   :3; 
//   Ucbit   ARSCE      :1;   /* Auto read speed control enabled */ 
//   Ucbit   AWSCD      :1;   /* Auto write speed control disabled */ 
//   Ucbit   res_3_67   :2; 
//   Uchar   link_counter[2];   /* Burn-Free link counter */ 
//   Uchar   res[10];      /* Padding up to 16 bytes */ 
//};

typedef struct SCSI_Cdb_Generic6_s {
   unsigned int CommandCode   : 8;
   unsigned int Reserved1     : 5;
   unsigned int Lun           : 3;
   unsigned int Reserved2     : 8;
   unsigned int Reserved3     : 8;
   unsigned int Reserved4     : 8;
   unsigned int Link          : 1;
   unsigned int Flag          : 1;
   unsigned int Reserved5     : 4;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_Generic6_t;

typedef struct SCSI_Cdb_TestUnitReady_s {
   unsigned int CommandCode   : 8;  /* should be 0x00 */
   unsigned int               : 5;  /* must be 0 */
   unsigned int Lun        : 3;
   unsigned int            : 8;  /* must be 0 */
   unsigned int            : 8;
   unsigned int            : 8;
   unsigned int Link       : 1;
   unsigned int Flag       : 1;
   unsigned int            : 4;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_TestUnitReady_t;

typedef struct SCSI_Cdb_Rewind_s {
   unsigned int CommandCode   : 8;  /* should be 0x01 */
   unsigned int Immediate     : 1;
   unsigned int            : 4;
   unsigned int Lun        : 3;
   unsigned int            : 8;
   unsigned int            : 8;
   unsigned int            : 8;
   unsigned int Link       : 1;
   unsigned int Flag       : 1;
   unsigned int            : 4;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_Rewind_t;

typedef struct SCSI_Cdb_RequestSense_s {
   unsigned int CommandCode      : 8;  /* should be 0x03 */
   unsigned int               : 5;  /* must be 0 */
   unsigned int Lun           : 3;
   unsigned int               : 8;  /* must be 0 */
   unsigned int               : 8;
   unsigned int AllocationLength : 8;
   unsigned int Link          : 1;
   unsigned int Flag          : 1;
   unsigned int               : 4;
   unsigned int VendorSpecific      : 2;
   } SCSI_Cdb_RequestSense_t;

typedef struct SCSI_SenseData_s {
   unsigned int ErrorCode           : 7;
   unsigned int Valid               : 1;
   unsigned int SegmentNumber       : 8;
   unsigned int SenseKey            : 4;
   unsigned int                  : 1;
   unsigned int IllegalLength       : 1;
   unsigned int EndOfMedia          : 1;
   unsigned int FileMark            : 1;
   unsigned int InformationByte3    : 8;
   unsigned int InformationByte2    : 8;
   unsigned int InformationByte1    : 8;
   unsigned int InformationByte0    : 8;
   unsigned int AdditionalLength    : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int Asc              : 8;
   unsigned int Asq              : 8;
   unsigned int                  : 8;
   unsigned int BitPointer          : 3;
   unsigned int BitPointerValid     : 1;
   unsigned int                  : 2;
   unsigned int CdbError            : 1;
   unsigned int SenseKeySpecificValid  : 1;
   } SCSI_SenseData_t;

// Sense keys
#define SCSI_Skey_NoSense        0x00
#define SCSI_Skey_RecoveredError 0x01
#define SCSI_Skey_NotReady       0x02
#define SCSI_Skey_MediumError    0x03
#define SCSI_Skey_HardwareError     0x04
#define SCSI_Skey_IllegalRequest 0x05
#define SCSI_Skey_UnitAttention     0x06
#define SCSI_Skey_DataProtect    0x07
#define SCSI_Skey_BlankCheck     0x08
#define SCSI_Skey_VendorSpecific 0x09
#define SCSI_Skey_CopyAborted    0x0A
#define SCSI_Skey_AbortedCommand 0x0B
#define SCSI_Skey_Equal          0x0C
#define SCSI_Skey_VolumeOverflow 0x0D
#define SCSI_Skey_Miscompare     0x0E
#define SCSI_Skey_Reserved       0x0F

typedef struct SCSI_Cdb_ReadBlockLimits_s {
   unsigned int CommandCode   : 8;  /* should be 0x05 */
   unsigned int            : 5;
   unsigned int Lun        : 3;
   unsigned int            : 8;
   unsigned int            : 8;
   unsigned int            : 8;
   unsigned int Link       : 1;
   unsigned int Flag       : 1;
   unsigned int            : 4;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_ReadBlockLimits_t;

typedef struct SCSI_BlockLimits_s {
   unsigned int               : 8;
   unsigned int MaxBlockSize2    : 8;
   unsigned int MaxBlockSize1    : 8;
   unsigned int MaxBlockSize0    : 8;
   unsigned int MinBlockSize1    : 8;
   unsigned int MinBlockSize0    : 8;
   } SCSI_BlockLimits_t;

typedef struct SCSI_Cdb_Read_s {
   unsigned int CommandCode      : 8;  /* should be 0x08 */
   unsigned int LBA2             : 5;
   unsigned int Lun              : 3;
   unsigned int LBA1             : 8;
   unsigned int LBA0             : 8;
   unsigned int Length           : 8;
   unsigned int Link             : 1;
   unsigned int Flag             : 1;
   unsigned int                  : 4;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_Read_t;


typedef struct SCSI_Cdb_Write_s {
   unsigned int CommandCode         : 8;  /* should be 0x08 */
   unsigned int Fixed               : 1;
   unsigned int                  : 4;
   unsigned int Lun              : 3;
   unsigned int Count2              : 8;
   unsigned int Count1              : 8;
   unsigned int Count0              : 8;
   unsigned int Link             : 1;
   unsigned int Flag             : 1;
   unsigned int                  : 4;
   unsigned int VendorSpecific         : 2;
   } SCSI_Cdb_Write_t;


typedef struct SCSI_Cdb_WriteFilemarks_s {
   unsigned int CommandCode   : 8;  /* should be 0x10 */
   unsigned int Immediate     : 1;
   unsigned int Setmark    : 1;
   unsigned int            : 3;
   unsigned int Lun        : 3;
   unsigned int Count2        : 8;
   unsigned int Count1        : 8;
   unsigned int Count0        : 8;
   unsigned int Link       : 1;
   unsigned int Flag       : 1;
   unsigned int            : 4;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_WriteFilemarks_t;

typedef struct SCSI_Cdb_Space_s {
   unsigned int CommandCode   : 8;  /* should be 0x11 */
   unsigned int Code       : 3;
   unsigned int            : 2;
   unsigned int Lun        : 3;
   unsigned int Count2        : 8;
   unsigned int Count1        : 8;
   unsigned int Count0        : 8;
   unsigned int Link       : 1;
   unsigned int Flag       : 1;
   unsigned int            : 4;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_Space_t;

typedef struct SCSI_Cdb_Inquiry_s {
   unsigned int CommandCode      : 8;  /* should be 0x12 */
   unsigned int Evpd          : 1;
   unsigned int               : 4;
   unsigned int Lun           : 3;
   unsigned int PageCode         : 8;
   unsigned int               : 8;
   unsigned int AllocationLength : 8;
   unsigned int Link          : 1;
   unsigned int Flag          : 1;
   unsigned int               : 4;
   unsigned int VendorSpecific      : 2;
   } SCSI_Cdb_Inquiry_t;

typedef struct SCSI_InquiryData_s {
   unsigned int DeviceType             : 5;
   unsigned int DeviceQualifier        : 3;
   unsigned int DeviceModifier            : 7;
   unsigned int RemovableMedia            : 1;
   unsigned int AnsiVersion            : 3;
   unsigned int EcmaVersion            : 3;
   unsigned int IsoVersion             : 2;
   unsigned int ResponseDataFormat        : 4;
   unsigned int                     : 2;
   unsigned int TermIoProcessSupport      : 1;
   unsigned int AsyncEventNotifySupport   : 1;
   unsigned int AdditionalLength       : 8;
   unsigned int                     : 8;
   unsigned int                     : 8;
   unsigned int SoftResetSupport       : 1;
   unsigned int CommandQueueSupport    : 1;
   unsigned int                     : 1;
   unsigned int LinkedCommandSupport      : 1;
   unsigned int SynchronousTransferSupport : 1;
   unsigned int WideBus16Support       : 1;
   unsigned int WideBus32Support       : 1;
   unsigned int RelativeAddressingSupport : 1;
   unsigned char VendorId[8];
   unsigned char ProductId[16];
   unsigned char ProductRevisionLevel[4];
   } SCSI_InquiryData_t;

typedef struct SCSI_Cdb_Erase_s {
   unsigned int CommandCode   : 8;
   unsigned int Long       : 1;
   unsigned int Immediate     : 1;
   unsigned int            : 3;
   unsigned int Lun        : 3;
   unsigned int            : 8;
   unsigned int            : 8;
   unsigned int            : 8;
   unsigned int Link       : 1;
   unsigned int Flag       : 1;
   unsigned int            : 4;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_Erase_t;

typedef struct SCSI_Cdb_Format_s {
   unsigned int CommandCode      : 8;
   unsigned int DefectListFormat : 3;
   unsigned int CompleteList     : 1;
   unsigned int FormatData       : 1;
   unsigned int Lun           : 3;
   unsigned int               : 8;
   unsigned int InterleaveByte1  : 8;
   unsigned int InterleaveByte0  : 8;
   unsigned int Link          : 1;
   unsigned int Flag          : 1;
   unsigned int               : 4;
   unsigned int VendorSpecific      : 2;
   } SCSI_Cdb_Format_t;

typedef struct SCSI_Cdb_LoadUnload_s {
   unsigned int CommandCode   : 8;  /* should be 0x1B */
   unsigned int Immediate     : 1;
   unsigned int               : 4;
   unsigned int Lun           : 3;
   unsigned int               : 8;
   unsigned int               : 8;
   unsigned int Start         : 1;
   unsigned int LoadEject     : 1;
   unsigned int               : 6;
   unsigned int Link          : 1;
   unsigned int Flag          : 1;
   unsigned int               : 4;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_LoadUnload_t;


typedef struct SCSI_Cdb_ModeSense_s {
   unsigned int CommandCode            : 8;  /* should be 0x1A */
   unsigned int                     : 3;
   unsigned int DisableBlockDescriptors   : 1;
   unsigned int                     : 1;
   unsigned int Lun                 : 3;
   unsigned int PageCode               : 6;
   unsigned int PageControl            : 2;
   unsigned int                     : 8;
   unsigned int AllocationLength       : 8;
   unsigned int Link                : 1;
   unsigned int Flag                : 1;
   unsigned int                     : 4;
   unsigned int VendorSpecific            : 2;
   } SCSI_Cdb_ModeSense_t;

typedef struct SCSI_ModeSenseData_s {
   unsigned int SenseDataLength        : 8;
   unsigned int MediumType             : 8;
   unsigned int Device_Specific        : 8;
   unsigned int BlockDescriptorLength     : 8;
   unsigned int DensityCode            : 8;
   unsigned int NumBlocks2             : 8;
   unsigned int NumBlocks1             : 8;
   unsigned int NumBlocks0             : 8;
   unsigned int Reserved1              : 8;
   unsigned int BlockLength2           : 8;
   unsigned int BlockLength1           : 8;
   unsigned int BlockLength0           : 8;
   } SCSI_ModeSenseData_t;

typedef struct SCSI_Cdb_ModeSelect_s {
   unsigned int CommandCode            : 8;  /* should be 0x1A */
   unsigned int SavePages              : 1;
   unsigned int                     : 3;
   unsigned int PageFormat             : 1;
   unsigned int Lun                 : 3;
   unsigned int                     : 8;
   unsigned int                     : 8;
   unsigned int ParameterListLength    : 8;
   unsigned int Link                : 1;
   unsigned int Flag                : 1;
   unsigned int                     : 4;
   unsigned int VendorSpecific            : 2;
   } SCSI_Cdb_ModeSelect_t;

typedef struct SCSI_ModeSelectData_s {
   unsigned int                     : 8;
   unsigned int                     : 8;
   unsigned int Speed                  : 4;
   unsigned int BufferedMode           : 3;
   unsigned int                     : 1;
   unsigned int BlockDescriptorLength     : 8;
   unsigned int DensityCode            : 8;
   unsigned int NumBlocks2             : 8;
   unsigned int NumBlocks1             : 8;
   unsigned int NumBlocks0             : 8;
   unsigned int                     : 8;
   unsigned int BlockLength2           : 8;
   unsigned int BlockLength1           : 8;
   unsigned int BlockLength0           : 8;
   } SCSI_ModeSelectData_t;



typedef struct SCSI_Cdb_ReserveUnit_s {
   unsigned int CommandCode            : 8;  /* should be 0x16 */
   unsigned int                     : 1;
   unsigned int ThirdPartyDeviceId        : 3;
   unsigned int ThirdPartyFlag            : 1;
   unsigned int Lun                 : 3;
   unsigned int                     : 8;
   unsigned int                     : 8;
   unsigned int                     : 8;
   unsigned int Link                : 1;
   unsigned int Flag                : 1;
   unsigned int                     : 4;
   unsigned int VendorSpecific            : 2;
   } SCSI_Cdb_ReserveUnit_t;

typedef struct SCSI_Cdb_ReleaseUnit_s {
   unsigned int CommandCode            : 8;  /* should be 0x17 */
   unsigned int                     : 1;
   unsigned int ThirdPartyDeviceId        : 3;
   unsigned int ThirdPartyFlag            : 1;
   unsigned int Lun                 : 3;
   unsigned int                     : 8;
   unsigned int                     : 8;
   unsigned int                     : 8;
   unsigned int Link                : 1;
   unsigned int Flag                : 1;
   unsigned int                     : 4;
   unsigned int VendorSpecific            : 2;
   } SCSI_Cdb_ReleaseUnit_t;


typedef struct SCSI_Cdb_SendDiagnostic_s {
   unsigned int CommandCode      : 8;  /* should be 0x12 */
   unsigned int UnitOfflineOk    : 1;
   unsigned int DeviceOfflineOk  : 1;
   unsigned int SelfTest         : 1;
   unsigned int               : 1;
   unsigned int PageFormat       : 1;
   unsigned int Lun           : 3;
   unsigned int               : 8;
   unsigned int ParmListLenByte1 : 8;
   unsigned int ParmListLenByte0 : 8;
   unsigned int Link          : 1;
   unsigned int Flag          : 1;
   unsigned int               : 4;
   unsigned int VendorSpecific      : 2;
   } SCSI_Cdb_SendDiagnostic_t;

typedef struct SCSI_Cdb_ReadCapacity_s {
   unsigned int CommandCode      : 8;  /* should be 0x25 */
   unsigned int RelAdr           : 1;
   unsigned int                  : 4;
   unsigned int Lun              : 3;
   unsigned int LBA3             : 8;
   unsigned int LBA2             : 8;
   unsigned int LBA1             : 8;
   unsigned int LBA0             : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int Partial          : 1;
   unsigned int Partition        : 7;
   unsigned int Link             : 1;
   unsigned int Flag             : 1;
   unsigned int                  : 4;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_ReadCapacity_t;


typedef struct SCSI_ReadCapacityData_s {
   unsigned int BlockAddress3    : 8;
   unsigned int BlockAddress2    : 8;
   unsigned int BlockAddress1    : 8;
   unsigned int BlockAddress0    : 8;
   unsigned int BlockSize3       : 8;
   unsigned int BlockSize2       : 8;
   unsigned int BlockSize1       : 8;
   unsigned int BlockSize0       : 8;
   } SCSI_ReadCapacityData_t;


typedef struct SCSI_Cdb_Locate_s {
   unsigned int CommandCode         : 8;  /* should be 0x2B */
   unsigned int Immediate           : 1;
   unsigned int ChangePartition     : 1;
   unsigned int BlockType           : 1;
   unsigned int                  : 2;
   unsigned int Lun              : 3;
   unsigned int                  : 8;
   unsigned int Count3              : 8;
   unsigned int Count2              : 8;
   unsigned int Count1              : 8;
   unsigned int Count0              : 8;
   unsigned int                  : 8;
   unsigned int Partition           : 8;
   unsigned int Link             : 1;
   unsigned int Flag             : 1;
   unsigned int                  : 4;
   unsigned int VendorSpecific         : 2;
   } SCSI_Cdb_Locate_t;


typedef struct SCSI_Cdb_ReadPosition_s {
   unsigned int CommandCode         : 8;  /* should be 0x34 */
   unsigned int BlockType           : 1;
   unsigned int                  : 4;
   unsigned int Lun              : 3;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int Link             : 1;
   unsigned int Flag             : 1;
   unsigned int                  : 4;
   unsigned int VendorSpecific         : 2;
   } SCSI_Cdb_ReadPosition_t;


typedef struct SCSI_ReadPositionData_s {
   unsigned int                  : 2;
   unsigned int BlockPositionUnknown   : 1;
   unsigned int                  : 3;
   unsigned int EndOfPartition         : 1;
   unsigned int BeginningOfPartition   : 1;
   unsigned int Partition           : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int FirstBlock3         : 8;
   unsigned int FirstBlock2         : 8;
   unsigned int FirstBlock1         : 8;
   unsigned int FirstBlock0         : 8;
   unsigned int LastBlock3          : 8;
   unsigned int LastBlock2          : 8;
   unsigned int LastBlock1          : 8;
   unsigned int LastBlock0          : 8;
   unsigned int                  : 8;
   unsigned int BlocksInBuffer2     : 8;
   unsigned int BlocksInBuffer1     : 8;
   unsigned int BlocksInBuffer0     : 8;
   unsigned int BytesInBuffer3         : 8;
   unsigned int BytesInBuffer2         : 8;
   unsigned int BytesInBuffer1         : 8;
   unsigned int BytesInBuffer0         : 8;
   } SCSI_ReadPositionData_t;


typedef struct SCSI_Cdb_PreventAllow_s {
   unsigned int CommandCode   : 8;
   unsigned int Reserved1     : 5;
   unsigned int Lun           : 3;
   unsigned int Reserved2     : 8;
   unsigned int Reserved3     : 8;
   unsigned int Prevent       : 1;
   unsigned int Reserved4     : 7;
   unsigned int Link          : 1;
   unsigned int Flag          : 1;
   unsigned int Reserved5     : 4;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_PreventAllow_t;


typedef struct SCSI_Cdb_ReadToc_s {
   unsigned int CommandCode      : 8;  /* should be 0x43 */
   unsigned int                  : 1;
   unsigned int MSF              : 1;
   unsigned int                  : 3;
   unsigned int Lun              : 3;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int StartTrack       : 8;
   unsigned int Length1          : 8;
   unsigned int Length0          : 8;
   unsigned int Link             : 1;
   unsigned int Flag             : 1;
   unsigned int                  : 4;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_ReadToc_t;

typedef struct SCSI_Cdb_ReportKey_s {
   unsigned int CommandCode      : 8;  /* should be 0xA4 */
   unsigned int                  : 5;
   unsigned int Lun              : 3;
   unsigned int Lba              : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int                  : 8;
   unsigned int Reserved         : 8;
   unsigned int Keyclass         : 8;
   unsigned int Allocationlen    : 8;
   unsigned int                  : 8;
   unsigned int Keyformat        : 6;
   unsigned int AGID             : 2;
   unsigned int Link             : 1;
   unsigned int Flag             : 1;
   unsigned int NACA			 : 1;
   unsigned int					 : 3;
   unsigned int VendorSpecific   : 2;
   } SCSI_Cdb_ReportKey_t;

typedef struct SCSI_ReadTocData_s {
   unsigned int Length1          : 8;
   unsigned int Length0          : 8;
   unsigned int FirstTrack       : 8;
   unsigned int LastTrack        : 8;
   } SCSI_ReadTocData_t;

typedef struct SCSI_TocDescriptor_s {
   unsigned int                  : 8;
   unsigned int Control          : 4;
   unsigned int ADR              : 4;
   unsigned int TrackNumber      : 8;
   unsigned int                  : 8;
   unsigned int AbsAddress3      : 8;
   unsigned int AbsAddress2      : 8;
   unsigned int AbsAddress1      : 8;
   unsigned int AbsAddress0      : 8;
   } SCSI_TocDescriptor_t;

typedef struct _DiskGeometry_s{
   LARGE_INTEGER	Cylinders;
   MEDIA_TYPE		MediaType;
   DWORD			TracksPerCylinder;	
   DWORD			SectorsPerTrack;	
   DWORD			BytesPerSector;	
   } DiskGeometry_s;

#pragma pack(pop)

#endif
